import java.util.function.BiFunction;

@FunctionalInterface
interface RecursiveIntConsumer {
    void accept(int i, RecursiveIntConsumer self);
}

public class RecursiveLambdaExample {
    public static void main(String[] args) {
        RecursiveIntConsumer dfs = (i, self) -> {
            if (i == 100) return; // 终止条件
            System.out.println(i);
            self.accept(i + 1, self); // 递归调用
        };

        // 从1开始执行递归
        dfs.accept(1, dfs);

        BiFunction<Integer, Double, Double> func = Double::sum;
        System.out.println(func.apply(10, 20.2));

//        IntConsumer[] intConsumers = new IntConsumer[1];
//        intConsumers[0] = (i) -> {
//            if (100 == i) return;
//            System.out.println("i: " + i);
//            intConsumers[0].accept(i + 1);
//        };
//
//        intConsumers[0].accept(1);

//        BiFunction<Integer, Integer, Integer> sum = (Integer a, Integer b) -> a + b;
//        System.out.println(sum.apply(3, 4)); // 输出 7
    }
}
